/*
 * @Author: your name
 * @Date: 2020-09-13 10:05:33
 * @LastEditTime: 2020-09-13 14:12:47
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \woniutaofang\lib\pages\home\components\slivergrid_widget.dart
 */
import 'package:flutter/material.dart';

class SliverGridWidget extends StatefulWidget {
  SliverGridWidget({Key key}) : super(key: key);

  @override
  _SliverGridWidgetState createState() => _SliverGridWidgetState();
}

class _SliverGridWidgetState extends State<SliverGridWidget> {
  List slivergrid = [
    {"name": "新房", "code": "id1"},
    {"name": "帮我找房", "code": "id2"},
    {"name": "积分商城", "code": "id3"},
    {"name": "资讯动态", "code": "id4"},
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      child: InkWell(
        onTap: () {},
        child: Container(
          padding: EdgeInsets.all(8.0),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: _listView(),
          ),
        ),
      ),
    );
  }

  List<Widget> _listView() {
    return slivergrid
        .map(
          (f) => Container(
            child: InkWell(
              onTap: () => print(f),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  ClipOval(
                    child: Image.network(
                        'https://wx2.sinaimg.cn/mw690/66fa6be4gy1fzd1sif9tuj218g0p143d.jpg',
                        width: 60.0,
                        height: 60.0,
                        fit: BoxFit.cover),
                  ),
                  SizedBox(height: 5),
                  Text(f['name'])
                ],
              ),
            ),
          ),
        )
        .toList();
  }
}
